const { SyncBailHook } = require("tapable");

class HYCompiler {
  constructor() {
    this.hooks = {
      // bail的特点：如果有返回值，那么跨越阻断后续事件继续执行
      syncBailHook: new SyncBailHook(["name", "age"]),
    };

    this.hooks.syncBailHook.tap("event1", (name, age) => {
      console.log("event1事件执行了", name, age);
      return 123;
    });

    this.hooks.syncBailHook.tap("event2", (name, age) => {
      console.log("event1事件执行了", name, age);
    });
  }
}

setTimeout(() => {
  const compiler = new HYCompiler();
  compiler.hooks.syncBailHook.call("why", 23);
}, 2000);
